package messageprocessors.clients;

import java.util.HashMap;
import java.util.Map;


public class Artikel {

	protected int id;
	protected int barcode;
	protected String name;
	public String status;
	public String station;
	public String understation;
	public Station stationinfo;
	public int bestand;
	public int bestellt;
	public String info;
	public Map<String, String> map;

	public Artikel(){
		this.id=0;
		this.barcode=1;
		this.name="";
		this.status="";
		this.station="";
		this.stationinfo=new Station();
		this.understation="";
		this.bestand=0;	
		this.bestellt=0;
		this.info="Es sind "+bestellt+" Einheiten bestellt";
		this.map = new HashMap<String, String>();
	}
	public void createMap(){
		this.map.put("id", convertIntToString(this.getId()));
		this.map.put("barcode", convertIntToString(this.getBarcode()));
		this.map.put("name", this.getName());
		this.map.put("status", this.getStatus());
		this.map.put("station", this.getStation());
		this.map.put("understation", this.getUnderstation());
		this.map.put("bestand", convertIntToString(this.getBestand()));
		this.map.put("bestellt", convertIntToString(this.getBestellt()));
		this.map.put("info", this.getInfo());
	}

	
	public void createMaptoreadfromdDB(){
		
		this.map.put("id", convertIntToString(this.getId()));
		this.map.put("barcode", convertIntToString(this.getBarcode()));
		this.map.put("name", this.getName());
		this.map.put("bestand", convertIntToString(this.getBestand()));
		this.map.put("status", this.getStatus());
		this.map.put("station", this.getStation());
		this.map.put("understation", this.getUnderstation());
		this.map.put("bestellt", convertIntToString(this.getBestellt()));
		this.map.put("info", this.getInfo());
	}
	
	public void createMaptosendtoDB(){
		
		this.map.put("name", this.getName());
		this.map.put("bestand", convertIntToString(this.getBestand()));
		this.map.put("status", this.getStatus());
		this.map.put("station", this.getStation());
		this.map.put("understation", this.getUnderstation());
		this.map.put("bestellt", convertIntToString(this.getBestellt()));
		this.map.put("info", this.getInfo());
	}
	
	public Artikel generateArtikel(Map<String, String> creatmap){
		Artikel genArt=new Artikel();
		genArt.setId(Integer.parseInt(creatmap.get("id")));
		genArt.setBarcode(Integer.parseInt(creatmap.get("barcode")));
		genArt.setName(creatmap.get("name"));
		genArt.setStatus(creatmap.get("status"));
		genArt.setStation(creatmap.get("station"));
		genArt.setUnderstation(creatmap.get("understation"));
		genArt.setBestellt(Integer.parseInt(creatmap.get("bestellt")));
		genArt.setInfo(creatmap.get("info"));
		return genArt;
		
	}


	/**
	 * @return the bestellt
	 */
	public int getBestellt() {
		return bestellt;
	}

	/**
	 * @param bestellt bestellt to set
	 */
	public void setBestellt(int bestellt) {
		this.bestellt = bestellt;
	}

	/**
	 * @return the id
	 */
	public int getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(int id) {
		this.id = id;
	}

	/**
	 * @return the barcode
	 */
	public int getBarcode() {
		return barcode;
	}

	/**
	 * @param barcode the barcode to set
	 */
	public void setBarcode(int barcode) {
		this.barcode = barcode;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the status
	 */
	public String getStatus() {
		return status;
	}

	/**
	 * @param status the status to set
	 */
	public void setStatus(String status) {
		this.status = status;
	}

	/**
	 * @return the station
	 */
	public String getStation() {
		return station;
	}

	/**
	 * @param station the station to set
	 */
	public void setStation(String station) {	
		this.station = station;
	}

	/**
	 * @return the understation
	 */
	public String getUnderstation() {
		return understation;
	}

	/**
	 * @param understation the understation to set
	 */
	public void setUnderstation(String understation) {	
		this.understation = understation;
	}

	/**
	 * @return the bestand
	 */
	public int getBestand() {
		return bestand;
	}

	/**
	 * @param bestand the bestand to set
	 */
	public void setBestand(int bestand) {
		this.bestand = bestand;
	}

	/**
	 * @return the info
	 */
	public String getInfo() {
		return info;
	}

	/**
	 * @param info the info to set
	 */
	public void setInfo(String info) {
		this.info += info;
	}

	/**
	 * @return the map
	 */
	public Map<String, String> getMap() {
		return map;
	}

	/**
	 * @param map the map to set
	 */
	public void setMap(Map<String, String> map) {
		this.map = map;
	}
	
	

	/**
	 * @return the stationinfo
	 */
	public Station getStationinfo() {
		return stationinfo;
	}
	/**
	 * @param stationinfo the stationinfo to set
	 */
	public void setStationinfo(Station stationinfo) {
		this.stationinfo = stationinfo;
	}
	protected String convertIntToString(int val) {
		String str = "";
		str+= val;
		return str;	
	}



}
